<?

class SYS {

  public $domain;
  public $request;
  public $controller;
  public $action;
  public $parameters;

  function connectDB($db)
  {
    mysql_connect($db['host'],$db['user'],$db['password']) or die (mysql_error());
    mysql_select_db($db['name']);
  }

  function getStoreTemplate()
  {
    $SYS = $this;
    ob_start();
    include('stores/' . $this->domain . '/index.php');
    $html = ob_get_contents();
    ob_end_clean();

    session_start();
    $count=0;
    foreach ($_SESSION['products'] as $product=>$qty)
    {
      $count+=$qty;
    }

    $html = str_replace("{{CARTQTY}}", $count, $html);

    return $html;
  }

  function getModule($module,$options=null)
  {
    $SYS = $this;
    $module = str_replace('..','.',$module);

    ob_start();
    if ( file_exists('stores/'.$this->domain.'/modules/'.$module.'.php') )
    {
      include ('stores/'.$this->domain.'/modules/'.$module.'.php');
    }
    else
    {
      include ('modules/'.$module.'.php');
    }
    $result = ob_get_contents();
    ob_end_clean();

    return $result;
  }

}




?>